<?php

namespace Application\View\Helper;

use Zend\View\Helper\AbstractHelper;

class HeaderDetailsSejourHelper extends AbstractHelper {
	public function __invoke( $description ) {

		$this->root_url = $this->curPageURL();

		$description_twitter = substr($description, 0, 120);

		$navHtml = <<<EOQ
			<div id="header_bar">
				<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation">
		            <div class="container">
		                <div class="navbar-header">
		                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
		                        <span class="sr-only">Toggle navigation</span>
		                        <span class="icon-bar"></span>
		                        <span class="icon-bar"></span>
		                        <span class="icon-bar"></span>
		                    </button>
		                    <a class="navbar-brand" href="/">
		                    	1001 TREKS.com
		                    </a>
		                </div>
		                <!-- Collect the nav links, forms, and other content for toggling -->

		                <div class="collapse navbar-collapse navbar-ex1-collapse navbar-right">
		                    <ul class="nav navbar-nav">
		                        <li>
			                        <a target="_blank" title="Facebook" href="https://www.facebook.com/sharer.php?u=$this->root_url&t=$description" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=500,width=700');return false;">
			                            <i class="fa fa-facebook-square"></i>
			                            Partager
			                        </a>

			                    </li> 
			                    <li>
			                        <a target="_blank" title="Google +" href="https://plus.google.com/share?url=$this->root_url&hl=fr" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=450,width=650');return false;">
			                            <i class="fa fa-google-plus"></i>
			                            Google+
			                        </a>
			                    </li>
			                    <li>
			                        <a target="_blank" title="Twitter" href="https://twitter.com/share?url=''&text=$description_twitter&via=1001Treks" rel="nofollow" onclick="javascript:window.open(this.href, '', 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=700');return false;">
			                            <i class="fa fa-twitter"></i>
			                            Tweet
			                        </a>

			                    </li>
		                        <li><a href="/nous-contacter#nc">Nous contacter</a></li>
		                    </ul>
		                </div>

		                <!-- /.navbar-collapse -->
		            </div>
		            <!-- /.container -->
		        </nav>
			</div>
EOQ;
		
		return $navHtml;
	}

	function curPageURL() {
		$pageURL = 'http';
		// if ($_SERVER["HTTPS"] == "on") {
		// 	$pageURL .= "s";
		// }
		$pageURL .= "://";
		if ($_SERVER["SERVER_PORT"] != "80") {
			$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
		} else {
			$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
		}

		return $pageURL;
	}

}
